package practica2;

import weka.core.Instances;

/**
 * Train the classifier by means of k-NN. Evaluate according to cross validation, 
 * and based on the f-measure, determine which is the most appropriate value of k. 
 * Complete it exploring combinations of k, d and w.
 * 
 * Get the same result (or similar) using the following libraries:
 * weka.classifiers.meta.CVParameterSelection 
 * weka.classifiers.meta.GridSearch
 * 
 * @author luciarodero
 */
public class Main {
	
	public static void main(String[] args) throws Exception {
		
		//0. INFORMATION
		ShowResults sr = new ShowResults();
		sr.printInfo(args[0]);
		
		// 1. LOAD DATA FILE
		if( args.length < 1 ){
			System.out.println("ERROR: No has introducido argumentos");
			System.out.println("Ejemplo de uso: java -jar kNN.jar ~/ruta/archivo.arff");
			return; 
		}
		
		LoadDataFile ldf = new LoadDataFile(args[0]);
		Instances data = ldf.loadInstances();
		
		//2. FEATURE SUBSET SELECTION
		/*FeatureSubsetSelection fss = new FeatureSubsetSelection();
		Instances newData = fss.SubsetSelection(data);*/
		
		//3. CLASSIFY
		Classify c = new Classify();
		try{
			c.classifier(data);
		} catch (Exception e){
			e.printStackTrace();
		}
		
		//4. LIBRARYS
		CVParam cv = new CVParam();
		cv.paramSelection(data);
		GridSearch gs = new GridSearch();
		gs.gSearch(data);
    }
}
